//
//  ViewController.swift
//  cyshop
//
//  Created by duan on 2022/9/25.
//

import UIKit

class ViewController: UIViewController {
    
    var deviceSize = UIScreen.main.bounds;

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        self.view.backgroundColor = UIColor.orange;
        
        addUserNameView();
        addPassWorldView();
        addSubmitButton();
    }
    
    
    func addUserNameView(){
        
        let view = UIView(frame: CGRect.init(x: (deviceSize.width-250)*0.5, y: (deviceSize.height)*0.5-100, width: 250, height: 40));
        
        //view.backgroundColor = UIColor.blue;
        
        let label = UILabel(frame: CGRect.init(x: 0, y: 0, width: 40, height: 40));
        label.text = "账号:";
        
        
        let userNameTextField = UITextField(frame: CGRect.init(x: 50, y: 0, width: 200, height: 40));
        userNameTextField.textColor = UIColor.black;
        userNameTextField.borderStyle = UITextField.BorderStyle.roundedRect;
        
        view.addSubview(label);
        view.addSubview(userNameTextField);
        
        
        
        self.view.addSubview(view);
        
    }
    
    
    func addPassWorldView(){
        
        let view = UIView(frame: CGRect.init(x:(deviceSize.width-250)*0.5, y: (deviceSize.height)*0.5-50, width: 250, height: 40));
        
        //view.backgroundColor = UIColor.blue;
        
        let label = UILabel(frame: CGRect.init(x: 0, y: 0, width: 40, height: 40));
        label.text = "密码:";
        
        
        let passWorldTextField = UITextField(frame: CGRect.init(x: 50, y: 0, width: 200, height: 40));
        passWorldTextField.textColor = UIColor.black;
        passWorldTextField.borderStyle = UITextField.BorderStyle.roundedRect;
        
        view.addSubview(label);
        view.addSubview(passWorldTextField);
        
        
        self.view.addSubview(view);
        
    }
    
    func addSubmitButton(){
        //创建圆角按钮
        let button: UIButton = UIButton(type: .roundedRect)
        button.frame = CGRectMake((deviceSize.width-250)*0.5,(deviceSize.height)*0.5,250,40)
        button.backgroundColor = UIColor.black
        button.setTitle("登陆", for: .normal)
        button.setTitleColor(UIColor.white, for: .normal)
        button.layer.cornerRadius = 8

        
        self.view.addSubview(button);
        
    }


}

